using System.Diagnostics;
using System.Reflection;
using flickr.api.communication;

namespace flickr.api
{
	abstract public class FlickrObject
	{
        private const string _flickrNamespace = "flickr";
	    protected readonly FlickrConnection Connection;

	    public FlickrObject() : this(Flickr.Connection) {}
	    public FlickrObject(FlickrConnection connection)
	    {
	        Connection = connection;
	    }

	    protected virtual FlickrRequest CreateRequest(params FlickrParameter[] parameters)
	    {
	        StackTrace st = new StackTrace();
            MethodBase methodBase = st.GetFrame(1).GetMethod();
	        
	        FlickrRequest request = new FlickrRequest(string.Format("{0}.{1}.{2}", 
	                                               _flickrNamespace,
	                                               GetType().Name.ToLower(),
	                                               methodBase.Name));
	        
	        request.AddParameters(parameters);
            return request;
	    }
	    
	    protected virtual FlickrResponse Send(FlickrRequest request)
	    {
            return Connection.SendFlickrRequest(request);
	    }
	}

//    public class AuthenticatedFlickrObject : FlickrObject
//    {
//        protected override FlickrRequest CreateRequest(params FlickrParameter[] parameters)
//        {
//            FlickrRequest request = base.CreateRequest(parameters);
//            request.
//        }
//    }
}
